package net.bingosoft.common.struts;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ExceptionHandler;
import org.apache.struts.config.ExceptionConfig;

/**
 * 2007-8-3 上午11:18:06
 * Author:yangdongyu(yangdy@bingosoft.net)
 * ReadMe:Struts 的全局异常处理类,将异常在错误页面显示
 * ChangeLog:
 */
public class StrutsExceptionHandler extends ExceptionHandler {
	private Log log = LogFactory.getLog(StrutsExceptionHandler.class);
	
	@Override
	public ActionForward execute(Exception ex, ExceptionConfig config, ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException {
		ActionForward actionForward = super.execute(ex, config, mapping, form, request, response);
		log.warn(ex);
		log.debug("exeception happend ,forward to error page : " + actionForward.getPath());
		return actionForward;
	}


}
